Random-sampling mechanism